import Int from "../type/Q/int";

/**
 * 
 * @param {BigInt} num 
 * @returns 
 */
export default function isPrime(num) {
    if(!num instanceof BigInt) throw new TypeError('num must be BigInt')
    if(num == 1n) return false
    if(Int.primes.includes(num)) return true
    for (let i = 2n; i <= num/2n; i++)
        if (!(num % i)) return false;
    Int.prime = num
    return true;
}